package Client;

import javax.swing.JTextArea;
import javax.swing.text.DefaultCaret;

public class Reciever {
	String name;
	JTextArea chat;
	boolean isOnline = true;

	public Reciever(String RecieverName) {
		name = RecieverName;
	}

	public JTextArea getArea() {
		if (chat == null) {
			chat = this.createReciever();
		}
		return (chat);
	}

	public void write(String toWrite) {
		if (chat == null) {
			chat = this.createReciever();
		}
		chat.append(toWrite + "\n");

	}

	private JTextArea createReciever() {
		chat = new JTextArea(20, 30);
		DefaultCaret caret = (DefaultCaret) chat.getCaret();
		caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
		chat.setEditable(false);
		chat.setLineWrap(true);
		chat.setWrapStyleWord(true);
		return (chat);
	}
}